package model;

import base.BaseModel;
import base.BaseObserver;
import base.ResultCallBack;
import bean.BooksDatilBean;
import bean.ResultBean;
import jiyun.com.yiyanmeng.http.HttpManager;
import jiyun.com.yiyanmeng.http.MySerivce;
import presenter.BooksDatilPresenter;
import utils.RxUtil;

/**
 * Created by 裘翔 on 2019/11/8.
 */

public class BooksDatilModel extends BaseModel{

    public void loadData(final ResultCallBack<BooksDatilBean> callBack, int id) {
        MySerivce mySerivce = HttpManager.getInstance().getSerivce();
        mySerivce.getBooksDatil(id)
                .compose(RxUtil.<ResultBean<BooksDatilBean>>changeThread())
                .compose(RxUtil.<BooksDatilBean>changeResult())
                .subscribe(new BaseObserver<BooksDatilBean>() {
                    @Override
                    public void onSuccess(BooksDatilBean datilBean) {
                            callBack.onSuccess(datilBean);
                    }

                    @Override
                    public void onFail(String error) {
                            callBack.onFail(error);
                    }
                });
    }
}
